/**  
* @Title: AuthorityAction.java
* @Package cn.net.mtons.action.member.authority
* @Description: TODO
* @author ma jinjian  
* @date 2016年1月23日 下午5:51:07
* @version V1.0  
*/ 
package cn.net.mtons.web.member.authority;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.net.mtons.core.member.authority.AuthorityService;
import cn.net.mtons.model.entity.form.LoginForm;
import cn.net.mtons.model.entity.vo.AjaxResultVO;
import cn.net.mtons.model.entity.vo.MainMenuVO;
import cn.net.mtons.model.entity.vo.SystemUserVO;
import cn.net.mtons.model.entity.vo.TreeMenuVO;
import cn.net.mtons.model.entity.vo.WeX5VO;
import cn.net.mtons.web.BasicAction;
import cn.net.mtons.web.interfaces.authority.IAuthorityAction;

/**
 * @ClassName: AuthorityAction
 * @Description: TODO
 * @author ma jinjian
 * @date 2016年1月23日 下午5:51:07
 *
 */
@Controller
@RequestMapping(value="/authority")
public class AuthorityAction extends BasicAction implements IAuthorityAction {

	@SuppressWarnings("unused")
	private static Logger logger = Logger.getLogger("command");
	
	@SuppressWarnings("unused")
	private static Logger netLog = Logger.getLogger("netlog");
	
	@Autowired
	private AuthorityService authorityService;
	
	/* (non-Javadoc)
	 * @see cn.net.mtons.action.interfaces.authority.IAuthorityAction#login(cn.net.mtons.persist.entity.form.LoginForm)
	 */
	@Override
	public AjaxResultVO login(LoginForm form, HttpServletResponse response) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		AjaxResultVO vo = new AjaxResultVO();
		
		SystemUserVO user = new SystemUserVO();
		user.setAccountNumber("majinjian");
		user.setUserId("majinjian");
		user.setUserName("马金健");
		
		List<MainMenuVO> main = new ArrayList<MainMenuVO>();
		
		MainMenuVO menu1 = new MainMenuVO("账号管理");
		menu1.addTreeMenu(new TreeMenuVO("账户管理", "MTONS_001", "Account", true, false));
		main.add(menu1);
		
		MainMenuVO menu2 = new MainMenuVO("部门管理");
		menu2.addTreeMenu(new TreeMenuVO("部门管理", "MTONS_002", "Department", true, false));
		main.add(menu2);
		
		MainMenuVO menu3 = new MainMenuVO("权限管理");
		menu3.addTreeMenu(new TreeMenuVO("权限管理", "MTONS_003", "Authority", true, false));
		main.add(menu3);
		
		MainMenuVO menu4 = new MainMenuVO("会议管理");
		menu4.addTreeMenu(new TreeMenuVO("会议管理", "MTONS_004", "Meeting", true, false));
		main.add(menu4);
		
		MainMenuVO menu5 = new MainMenuVO("审批管理");
		menu5.addTreeMenu(new TreeMenuVO("审批管理", "MTONS_005", "Examine", true, false));
		main.add(menu5);
		
		user.setMenu(main);
		
		vo.success();
		vo.setData(user);
		
		return vo;
	}

	/* (non-Javadoc)
	 * @see cn.net.mtons.action.interfaces.authority.IAuthorityAction#logout()
	 */
	@Override
	public AjaxResultVO logout(HttpServletResponse response) {
		return null;
	}

	/* (non-Javadoc)
	 * @see cn.net.mtons.web.interfaces.authority.IAuthorityAction#list()
	 */
	@Override
	public AjaxResultVO list(HttpServletResponse response) {
		//跨域请求必须部分
		response.setHeader("Access-Control-Allow-Origin", "*");
		
		AjaxResultVO vo = new AjaxResultVO();
		List<WeX5VO> list= new ArrayList<WeX5VO>();
		WeX5VO v1 = new WeX5VO();
		v1.setUsername("马金健");
		v1.setDepartment("软件开发部");
		v1.setPosition("软件开发工程师");
		v1.setTelephone("13920532105");
		list.add(v1);
		
		WeX5VO v2 = new WeX5VO();
		v2.setUsername("刘娇");
		v2.setDepartment("销售部");
		v2.setPosition("销售员");
		v2.setTelephone("13752436193");
		list.add(v2);
		
		vo.setData(list);
		System.out.println("list:"+list);
		return vo;
	}
}
